#字典
alien = {'color':'gray','points':5}
print(alien)
alien['x_position'] = 0
alien['y_position'] = 25
print(alien)
alien_0 = {}
alien_0['color'] = 'orange'
alien_0['points'] = 6
print(alien_0)
del alien['points']
print(alien)#Hu
b = {'color':'black','speed':'slow'}
point_value = b.get('point','No point value assigned.')
print(point_value)
c = {'point':9,'color':'green'}
color_vale = c.get('color','No color value assigned.')
print(color_vale)
#学以致用、举一反三，人的信息：练习题发现字典查询里最多放两个对应量，不能多放否则会报错。
person = {'name':'Alice','age':18,'sex':'female','hobby':'tennis ball'}
Ainformation = person.get('hobby','None this information here.')
print(f"Alice's hobby is {Ainformation}")
#遍历字典
user = {'uname':'Dave','first':'duck','last':'cave'}
for key,values in user.items():
    print(f"\nKey:{key}")
    print(f"Value:{values}")
favorite_languages = {'Cave':'java','Saha':'python','Pill':'c++','Erid':'matlab'}
friends = ['Pill','Shah','Erid','Nide']
for name in favorite_languages.keys():
    print(f"Hi {name.title()}.")
    if name in friends:
        language = favorite_languages[name].title()
        print(f"\t{name.title()},I see tyou love {language}!")
for Name in sorted(favorite_languages.keys()):
    print(f"{Name.title()},thank you for taking the poll.")
print("The courses mentioned including below:")
for language in set(favorite_languages.values()):
    print(language.title())
#嵌套
x = {'color':'red','point':5}
y = {'color':'green','point':8}
z = {'color':'white','point':1}
ds = [x, y, z]
for d in ds:
    print(d)
ffrs = []
for ffr_number in range(30):
    new_ffr = {'color':'blue','point':7,'speed':'quckily'}
    ffrs.append(new_ffr)
for ffr in ffrs[:5]:
    print("…")
print(f"Total number of ffrs:{len(ffrs)}.")
for ffr in ffrs[0:3]:
    if ffr['color'] == 'green':
        ffr['color'] == 'yellow'
        ffr['speed'] == 'medium'
        ffr['points'] == 12
    elif ffr['color'] == 'yellow':
        ffr['color'] == 'red'
        ffr['speed'] == 'fast'
        ffr['points'] == 15
#在字典中存储列表和字典：
for name,language in favorite_languages.items():
    print(f"\n{name.title()}'s favorite languages are: ")
    print(f"\t{language.title()}")
users = {'am':{'first':'Albert','last':'file','location':'pribeijin'},'bs':{'first':'Loan','last':'Crazy','location':'npris'}}
for username,user_info in users.items():
    print(f"\nUsername:{username}")
    full_name = f"{user_info ['first']} ·{user_info['last']}"
    location = user_info['location']

    print(f"\tFull name: {full_name.title()}")
    print(f"\tLocation: {location.title() }")
